package emuLoader.gui.manager;

import java.io.IOException;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import nayasis.common.device.input.GamePadEventManager;
import nayasis.common.ui.javaFx.GuiUtil;

public class Launcher extends Application {

	@Override
	public void start( Stage stage ) throws IOException {
		
		GamePadEventManager.getInstance().start();
		
		stage.setTitle( "EmuLoader (contact to nayasis@gmail.com)" );
		
		stage.setScene( new Scene(GuiUtil.getPane("RomSelector.fxml")) );
		
		stage.addEventHandler( WindowEvent.WINDOW_CLOSE_REQUEST, new EventHandler<WindowEvent>() {
			public void handle( WindowEvent event ) {
				GamePadEventManager.getInstance().stop();
			}
		});
		
		stage.show();
		
	}

	public static void main( String[] args ) {

		launch( args );
		
	}
	
}
